<template>
	<view class="contnet">
		<!-- <hxNavbar :config="config"></hxNavbar> -->
		<f-navbar title="收货地址" fontColor="#333" fontSize="34" bgColor="#fff">
			<view class="u-flex" slot="left">
				<van-icon name="arrow-left" color="#333" size="20"/>
			</view>
		</f-navbar>
		<view class="content_box">
			<view class="address_box">
				<view class="address_item" v-for="(item,index) in dataList" :key="index" @click="onedit(item)">
					<view class="address_itemtoast" v-if="item.type==1">默认</view>
					<view class="address_itemtoast1" v-else></view>
					<view class="address_info">
						<view class="address_infoone">
							<view class="address_infoname">{{item.name}} {{item.phone}}</view>
							<view class="delete" @click.stop="ondelete(item.code)">
								删除
							</view>
						</view>
						
						<view class="address_infotxt">地址：{{item.full_address}}</view>
					</view>
					<van-icon name="arrow" size="20" color="#999"/>
				</view>
		<!-- 		<view class="address_item">
					<view class="address_itemtoast"></view>
					<view class="address_info">
						<view class="address_infoname">徐中山 185****1208</view>
						<view class="address_infotxt">地址：河北省廊坊市香河县淑阳镇云天国际3B1310室</view>
					</view>
					<van-icon name="arrow" size="20" color="#999"/>
				</view>
				<view class="address_item">
					<view class="address_itemtoast"></view>
					<view class="address_info">
						<view class="address_infoname">徐中山 185****1208</view>
						<view class="address_infotxt">地址：河北省廊坊市香河县淑阳镇云天国际3B1310室</view>
					</view>
					<van-icon name="arrow" size="20" color="#999"/>
				</view> -->
			</view>
		</view>
		<view class="submit" @click="addAddress">新建收货地址</view>
	</view>
</template>

<script>
	import fNavbar from '@/uni_modules/f-navbar/components/f-navbar/f-navbar.vue';
	import {getAddressList,delAddress} from '../../../utils/app.js'
	export default {
		components: {
			fNavbar
		},
		data() {
			return {
				active:'1',
				navHeight:0, //导航栏的高度
				imgurl: getApp().globalData.imgurl,
				dataList:[]
			}
		},
		created() {
			this.getList()
		},
		methods:{
			//点击删除地址
			ondelete(code){
				console.log(code);
				delAddress({
					code:code
				}).then(res => {
					console.log(res);
					if(res.code==1){
						this.getList()
					}
					// this.dataList = res.data
					// this.SystemCateList = res.data
					// this.getSystemBanner(this.active)
					// this.getHomeData(true)
					// this.dataList = res.data
				
				})
				
			},
			// 点击编辑跳转到页面
			onedit(e){
				uni.navigateTo({
					url:'/pages/subPack/addAddress/addAddress?address='+JSON.stringify(e)
				})
			},
			// 获取数据
			getList(){
				getAddressList({
					
				}).then(res => {
					console.log(res);
					if(res.code==1){
						this.dataList = res.data
					}else {
						uni.showToast({
							icon:'none',
							title:res.info,
							duration:1000
						})
						if(res.info=='请先登录'){
							setTimeout(function(){
								uni.navigateTo({
									url: '/pages/subPack/Login/Login'
								})
							},1000)
						}
					}

					// this.SystemCateList = res.data
					// this.getSystemBanner(this.active)
					// this.getHomeData(true)
					// this.dataList = res.data
				
				})
			},
			// 新增地址
			addAddress(){
				uni.navigateTo({
					url:'/pages/subPack/addAddress/addAddress'
				})
			},
		}
		}
</script>

<style>
	page{
		background: #eee;
	}
	.content_box{
		margin-top: 4rpx;
	}
	.address_box{
		width: 100%;
		/* height: 198rpx; */
		background: #fff;
	}
	.address_item{
		width: 690rpx;
		min-height: 198rpx;
		/* background: #000; */
		border-bottom: 1rpx solid #eee;
		margin: 0 auto;
		display: flex;
		align-items: center;
		padding: 20rpx 0;
		box-sizing: border-box;
	}
	.address_itemtoast{
		width: 64rpx;
		height: 30rpx;
		background: url(https://yuanchubao.oss-cn-beijing.aliyuncs.com/address_morenicon.png) no-repeat;
		background-size: contain;
		font-size: 22rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #FFFFFF;
		line-height: 30rpx;
		text-align: center;
	}
	.address_itemtoast1{
		width: 64rpx;
		height: 30rpx;
/* 		background: url(https://yuanchubao.oss-cn-beijing.aliyuncs.com/address_morenicon.png) no-repeat;
		background-size: contain; */
		font-size: 22rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #FFFFFF;
		line-height: 30rpx;
		text-align: center;
	}
	.address_info{
		display: flex;
		flex-direction: column;
		justify-content: center;
		/* align-items: center; */
		margin-left: 20rpx;
	}
	.address_infoone{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 30rpx;
	}
	.delete{
		font-size: 28rpx;
		color: #ddd;
		margin-right: -25rpx;
	}
	.address_infoname{
		font-size: 30rpx;
		font-family: Hiragino Sans GB;
		font-weight: 700;
		color: #333333;
		/* line-height: 55rpx; */
	}
	.address_infotxt{
		width: 570rpx;
		min-height: 80rpx;
		font-size: 28rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #333333;
		/* line-height: 55rpx; */
	}
	.submit{
		width: 100%;
		height: 98rpx;
		background: #EF0E6C;
		position: fixed;
		bottom: 0;
		font-size: 32rpx;
		font-family: Hiragino Sans GB;
		font-weight: normal;
		color: #FFFFFF;
		line-height: 98rpx;
		text-align: center;
	}
</style>